package answer_ioexcept;



import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 1:将课上练习独立敲一次
 * 2:完成下列要求:
 * 完成一个简易的记事本工具
 * 要求:
 * 程序启动后,将用户在控制台上输入的每一行内容都陆续写入到文件note.txt中
 * 当用户单独输入了"exit"则程序退出
 *
 *
 */
public class Answer {


    public Answer() throws FileNotFoundException, IOException {
    }

    public static void main(String[] args) throws IOException {

        FileWriter writer = new FileWriter("note.txt");
        writer.close();
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.print("请输入内容（输入 exit 退出）：");
            String line = sc.nextLine();
            if ("exit".equalsIgnoreCase(line)) {
                break;
            }
            FileWriter writer1 = new FileWriter("note.txt", true);
            writer1.write(line+"\n");
            writer1.close();

        }

    }
}














